import network


def connect_wifi(account: str, password: str):
    wlan = network.WLAN(network.STA_IF)  # 创建工作站
    wlan.active(True)  # 激活接口
    wlan.scan()  # 扫描接入点
    print(f"开始连接到{account}")
    wlan.connect(account, password)  # 连接到路由器，只支持2.4g
    ipconfig = wlan.ifconfig()  # 获取IP地址等信息
    print(ipconfig)
    return wlan


if __name__ == "__main__":
    wlan = connect_wifi("12-303", "17762388816")
    # wlan.disconnect() # 关闭连接
